#include <iostream>
#include <thread>
#include <future>
#include <chrono>

void Add(int num1,int num2,std::promise<int> &prom)
{
    std::cout<<"执行ing"<<std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(3));
    prom.set_value(num1+num2);
    return ;
}

int main()
{
    std::promise<int> prom;
    std::future<int> fu = prom.get_future();
    std::cout<<"----------------1----------------"<<std::endl;
    std::thread thr(Add,11,22,std::ref(prom));
    std::cout<<"----------------2----------------"<<std::endl;
    int ret = fu.get();
    std::cout<<"结果是"<<ret<<std::endl;
    thr.join();
    return 0;
}